{include file="public/header"/}

<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-picture-edit">

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>编号：</label>
			<td><option value="">{$a['id']}</option></td>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>图片标题：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" placeholder="名称" name="title" value="{$a.title}" id="title" style="width: 350px;">
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>图片详情：</label>
			<td><img src="__STATIC__/images/{$a['pic']}" style="width: 150px;"></td>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">上传图片：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div class="uploader-thum-container">
					<div id="filePicker"></div><input  type="file" name="pic" id="fileId"/>

				</div>
			</div>
		</div>
		<input type="hidden" name="id" value="{$a['id']}">
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button class="btn btn-primary radius" lay-submit lay-filter="formDemo"><i class="Hui-iconfont">&#xe632;</i> 提交</button>
			</div>
		</div>
	</form>
</article>

{include file="public/footer"/}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/webuploader/0.1.5/webuploader.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="__STATIC__/admin/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        //表单验证
        $("#form-picture-edit").validate({

            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var files = document.getElementById('fileId').files;
                var fileSize = 0;
                if(files.length!=0){
                    fileSize = files[0].size;
                }
                if(fileSize >2567800){
                    layer.msg('文件不能大于2M',{icon:2,time:1000});
                    return false;
                }

                if(document.getElementById("fileId").value == null || document.getElementById("fileId").value == "")
                {
                    layer.msg('商品图片不能为空！', {icon: 2, time: 2000});
                    return;
                }

                $(form).ajaxSubmit({
                    type: 'post',
                    url: "pictureEdit",
                    dataType:'json',
                    success:function (data) {
                        if (data){
                            layer.msg('修改失败！',{icon:2,time:3000});
                        }
                        if (data){
                            layer.msg('修改成功！',{icon:1,time:1000});
							setTimeout(function () {
                                window.parent.location.reload();
                                parent.layer.close();
                            },1000);
                        }
                    }
                });

            }
        });

    });
</script>

</body>
</html>